The present invention relates to a program module management system and a method thereof, and a storing medium of management programs of the system, in particular, in which program modules are loaded into a memory.
Conventionally, when a CPU fetches a program from a large capacity and low speed memory such as an external ROM (non-volatile memory), it is necessary to control such as that a wait is inserted at the read timing of the program from the memory. Consequently, there is a problem that the program fetching speed to the CPU is lowered.
FIG. 1 is a block diagram showing a structure of a micro computer of a first conventional example. As show in FIG. 1, the micro computer consists of a CPU 91, a ROM 92, a RAM 93, a program module A 94 storing in the ROM 92, and the program module A 95 loaded and storing in the RAM 93.
In FIG. 1, the RAM 93, to which the CPU 91 can fetch a program module at a high speed, is connected to the CPU 91, and the program module is loaded into the RAM 93, and the program module is executed by the CPU 91. This operation is explained in detail. The program module A 94 storing in an arbitrary address of the ROM 92 is loaded into an arbitrary address of the RAM 93 by the CPU 91. And a program counter (PC) of the CPU 91 is set at the start address of the program module A 95 loaded and storing in the RAM 93. With this, a high speed fetching on the RAM 93 by the CPU 91 is realized.
Japanese Patent Application Laid-Open No. SHO 63-228249 discloses a program loading system. In this application, a RAM, which program modules are loaded into, is used efficiently. And Japanese Patent Application Laid-Open No. SHO 59-114602 discloses a programmable controller. In this application, program modules, which are loaded into a RAM, are controlled.
FIG. 2 is a block diagram showing a structure of the program loading system described in the Japanese Patent Application Laid-Open No. SHO 63-228249 as the first conventional example. In this application, a main memory which the program modules are loaded into is used efficiently.
As shown in FIG. 2, the program loading system at the first conventional example consists of an automatically address deciding unit 101, an address designating unit 102, a parameter 103, and a main memory 104.
The automatically address deciding unit 101 decides the loading address of a program module by allocating in order from the lower address of a memory, like a conventional program loading system. The address designating unit 102 decides the loading address of a program module by allocating in order from the upper address of the memory. The parameter 103 is a parameter that designates whether the automatically address deciding unit 101 or the address designating unit 102 is used as the program loading system for the program module. And the program module is allocated on the main memory 104 by one of the loading systems of the automatically address deciding unit 101 and the address designating unit 102 under control of its operating system (OS).
FIG. 3 is a diagram showing the operation at the program loading system shown in FIG. 2 at the first conventional example. Referring to FIG. 3, the operation at the program loading system of the first conventional example is explained. FIG. 3(a) shows a state that an OS loads an application program. As shown in FIG. 3(a), an application program 113 is loaded into the lower address of the main memory 104 by the OS. After this, when the application program 113 storing in the main memory 104 loads a module of OS 112, since the program module to be loaded is a module related to the OS, as shown in FIG. 3(b), the module of OS 112 is loaded into the upper address by the program designating unit 102.
After this, when the application program 113 was executed and finished, as shown in FIG. 3(c), the memory area occupied by the application program 113 was made to be empty, and an empty area occurs in the main memory 104.
As mentioned above, the module of OS 112 was loaded soon after the application program 113 had been loaded, and the application program 113 was executed and finished and the area of the application program 113 was made to be empty. When these operation is continued and some application programs in all the application programs loaded into the main memory 104 are executed and areas of the executed application programs are made to be empty, discontinuing empty areas may occur in the main memory 104, and there is a problem that the main memory 104 cannot be utilized efficiently.
FIG. 4 is a block diagram showing a structure of the programmable controller at the Japanese Patent Application Laid-Open No. SHO 59-114602 as a second conventional example. The programmable controller controls program modules storing in a RAM by using a program loader.
As shown in FIG. 4, the programmable controller consists of a CPU 121, a ROM 122, a RAM 123, an I/O 124, an I/F 125, and a program loader 126.
The CPU 121 is a central processing unit and executes operation processes, and also executes sequence processes with the program loader 126. The ROM 122 stores programs that control and execute the operation processes, and also stores programs that control an interface with the program loader 126 and a mode control. The RAM 123 stores program modules and data required to execute programs in the ROM 122. The I/O 124 is an interface that outputs signals to external processes and inputs signals from the external processes. The I/F 125 is an interface that transfers data to and from the program loader 126 and generally uses a serial transfer. The program loader 126 calculates the empty area in the RAM 123 and makes the RAM 123 load the program modules from the ROM 122.
Next, at the second conventional example, the operation of loading processes of program modules at the programmable controller is explained. An OS storing in the ROM 122 transfers the start address and the size of each of the program modules storing in the RAM 123 to the program loader 126, by an interruption command from the program loader 126.
The program loader 126 confirms the size of a program module that is newly loaded and also confirms whether a program area, in which the new program module can be stored, exists in the RAM 123 or not. When it is possible that the new program module is stored, the program loader 126 calculates the start address of the new program module to be loaded and renews a management table in which the start address of each of the program modules storing in the RAM 123 is stored. When a request executing a program module is inputted from the I/O 124, the OS in the ROM 122 extracts the start address of the program module from the management table and makes the CPU 121 execute the program module.
However, there are several problems at the conventional program module management systems. First, at the first conventional example, it is necessary to keep the relative address between program modules. And when plural program modules are loaded, there is a problem that these plural program modules should be gathered together in a section.
Second, as mentioned above, at the case that a program module is set in plural different sections with other program modules as a loading unit, the same program module must be disposed in each of the plural different sections. Therefore, there is a problem that the capacity of the ROM is made to be large.
Furthermore, at the first and second conventional examples, there is a problem that a circuit, which manages and loads program modules in the RAM, is required. At the second conventional example, the program loader 126 is required.
Moreover, programs are executed on a RAM by a CPU, and when the capacity of the program modules is exceeded the capacity of the RAM, there is a problem that some program modules exceeded the capacity of the RAM cannot be executed by the CPU.
And at the first conventional example, it is necessary that the program modules in the memory are managed from the both directions of the upper address and the lower address. Therefore, there is a problem that the management of the program modules becomes complex.
It is therefore an object of the present invention to provide a program module management system and a method thereof, and a storing medium of management programs of the system, in which plural program modules are loaded into arbitrary addresses in a RAM efficiently without loading the same program module in the RAM and the plural program modules can be executed on the RAM by a CPU. And another object of the present invention is to provide a program module management system and a method thereof, and a storing medium of management programs of the system, in which program modules exceeded the capacity of the RAM can be executed on the ROM by the CPU.
According to a first aspect of the present invention for achieving the objects mentioned above, there is provided a program module management system. The program module management system provides a CPU for executing programs and operation processes, a ROM for storing program modules, a loading RAM which program modules are loaded into, and a RAM in which variables and stacks being necessary for executing the programs are stored. And the ROM provides a list table in which each start address of the program modules that are loaded into the loading RAM and each size of the program modules corresponding to the start address on the ROM are stored. And the loading RAM provides module management information in which each start address of the program modules storing in the loading RAM and each relative address of the program modules corresponding to the start address on the loading RAM are stored, in this, the relative address signifies the absolute value of the difference between each start address on the ROM and each start address on the loading RAM of each of the program modules=offset. And the program modules in the loading RAM are managed by management programs in the ROM.
According to a second aspect of the present invention in the first aspect, at the case that a program module group, which needs to be executed, already exists in the loading RAM, the program module group is not newly loaded from the ROM into the loading RAM, and the program module group is executed on the loading RAM by the CPU.
According to a third aspect of the present invention in the first aspect, at the case that a program module group is required to execute, the required program module group is compared with program modules existing in the loading RAM based on the list table, and only program modules not existing in the loading RAM are extracted from the ROM and are loaded into the loading RAM.
According to a fourth aspect of the present invention in the third aspect, at the case that the program modules are loaded into the loading RAM, the empty capacity of the loading RAM is compared with the capacity of the extracted program modules in the program module group, and when the empty capacity of the loading RAM is not sufficient for the total capacity of the extracted program modules judged to be loaded, unnecessary program modules are deleted from the loading RAM.
According to a fifth aspect of the present invention in the first aspect, at the case that a program module group is required to execute, the total capacity of the required program module group is compared with the total capacity of the loading RAM based on the list table, and when the total capacity of the loading RAM is large enough for the total capacity of the required program module group, all the module management information in the loading RAM is deleted, and the required program module group is loaded into the loading RAM.
According to a sixth aspect of the present invention in the fifth aspect, at the case that a program module group is required to execute, the total capacity of the required program module group is compared with the total capacity of the loading RAM based on the list table, and when the total capacity of the loading RAM is not sufficient for the total capacity of the required program module group, the program module group is executed on the ROM that stores the program module group.
According to a seventh aspect of the present invention in the first aspect, when the loading RAM is initialized, specified program modules are stationed permanently in the loading RAM, and the specified program modules are executed on the loading RAM without loading from the ROM.
According to an eighth aspect of the present invention in the seventh aspect, at the case that a program module group is required to execute, the total capacity of the required program module group is compared with the total capacity of the loading RAM except the capacity of the specified program modules based on the list table, and when the total capacity of the loading RAM except the capacity of the specified program modules is large enough for the total capacity of the required program module group, all the module management information in the loading RAM except that of the specified program modules is deleted, and the required program module group is loaded into the loading RAM.
According to a ninth aspect of the present invention in the seventh aspect, at the case that a program module group is required to execute, the total capacity of the required program module group is compared with the total capacity of the loading RAM except the capacity of the specified program modules based on the list table, and when the total capacity of the loading RAM except the capacity of the specified program modules is not sufficient for the total capacity of the required program module group, the program module group is executed on the ROM that stores the program module group.
According to a tenth aspect of the present invention, there is provided a program module management method at a program module management system. And the program module management system provides a CPU for executing programs and operation processes, a ROM for storing program modules, a loading RAM which program modules are loaded into, and a RAM in which variables and stacks being necessary for executing the programs are stored. And the ROM provides a list table in which each start address of the program modules that are loaded into the loading RAM and each size of the program modules corresponding to the start address on the ROM are stored. And the loading RAM provides module management information in which each start address of the program modules storing in the loading RAM and each relative address of the program modules corresponding to the start address on the loading RAM are stored, in this, the relative address signifies the absolute value of the difference between each start address on the ROM and each start address on the loading RAM of each of the program modules=offset. And the program module management method provides the steps of; judging whether a program module group loaded at the previous time and storing in the loading RAM is equal to a program module group in the list table that is requested to load into the loading RAM at this time or not, comparing program modules storing in the loading RAM with program modules in the program module group in the list table, when the judged result was not equal, extracting program modules that are required to newly load into the loading RAM based on the compared result, comparing the total capacity of the extracted program modules with the empty capacity of the loading RAM, loading the extracted program modules into the loading RAM when the empty capacity of the loading RAM is larger than the total capacity of the extracted program modules, and executing the program module group requested at this time on the loading RAM by the CPU.
According to an eleventh aspect of the present invention in the tenth aspect, the program module management method further provides the steps of; deleting unnecessary program modules in the loading RAM when the empty capacity of the loading RAM is smaller than the total capacity of the extracted program modules, comparing again the total capacity of the extracted program modules with the empty capacity of the loading RAM after the unnecessary program modules were deleted, loading the extracted program modules into the loading RAM when the empty capacity of the loading RAM is larger than the total capacity of the extracted program modules, and executing the program module group requested at this time on the loading RAM by the CPU.
According to a twelfth aspect of the present invention in the eleventh aspect, the program module management method further provides the steps of; comparing the total capacity of the program module group in the list table requested to be loaded with the total capacity of the loading RAM, when the empty capacity of the loading RAM after the unnecessary program modules were deleted is smaller than the total capacity of the extracted program modules, and executing the program module group requested at this time on the ROM by the CPU, when the total capacity of the program module group in the list table requested to be loaded is larger than the total capacity of the loading RAM.
According to a thirteenth aspect of the present invention in the twelfth aspect, the program module management method further provides the steps of; deleting all the module management information in the loading RAM, when the total capacity of the program module group in the list table requested to be loaded is smaller than the total capacity of the loading RAM, loading the program module group in the list table requested to be loaded into the loading RAM, and executing the program module group requested at this time on the loading RAM by the CPU.
According to a fourteenth aspect of the present invention in the tenth aspect, the program module management method further provides the steps of; stationing specified program modules permanently in the loading RAM when the loading RAM is initialized, and executing the specified program modules on the loading RAM without loading from the ROM by the CPU.
According to a fifteenth aspect of the present invention in the fourteenth aspect, the program module management method further provides the steps of; comparing the total capacity of the program module group in the list table requested to be loaded with the total capacity of the loading RAM except that for the program modules stationed permanently, when the empty capacity of the loading RAM after the unnecessary program modules were deleted is smaller than the total capacity of the extracted program modules, and executing the program module group requested at this time on the ROM by the CPU, when the total capacity of the program module group in the list table requested to be loaded is larger than the total capacity of the loading RAM except that for the program modules stationed permanently.
According to a sixteenth aspect of the present invention in the fourteenth aspect, the program module management method further provides the steps of; deleting all the module management information except that of the program modules stationed permanently in the loading RAM, when the total capacity of the program module group in the list table requested to be loaded is smaller than the total capacity of the loading RAM except that of the program modules stationed permanently, loading the program module group in the list table requested to be loaded into the loading RAM, and executing the program module group requested at this time on the loading RAM by the CPU.
According to a seventeenth aspect of the present invention, there is provided a storing medium of management programs at a program module management system. And the program module management system provides a CPU for executing programs and operation processes, a ROM for storing program modules, a loading RAM which program modules are loaded into, and a RAM in which variables and stacks being necessary for executing the programs are stored. And the ROM provides a list table in which each start address of the program modules that are loaded into the loading RAM and each size of the program modules corresponding to the start address on the ROM are stored. And the loading RAM provides module management information in which each start address of the program modules storing in the loading RAM and each relative address of the program modules corresponding to the start address on the loading RAM are stored, in this, the relative address signifies the absolute value of the difference between each start address on the ROM and each start address on the loading RAM of each of the program modules=offset. And the management programs provides the steps of; judging whether a program module group loaded at the previous time and storing in the loading RAM is equal to a program module group in the list table that is requested to load into the loading RAM at this time or not, comparing program modules storing in the loading RAM with program modules in the program module group in the list table, when the judged result was not equal, extracting program modules that are required to newly load into the loading RAM based on the compared result, comparing the total capacity of the extracted program modules with the empty capacity of the loading RAM, loading the extracted program modules into the loading RAM when the empty capacity of the loading RAM is larger than the total capacity of the extracted program modules, and executing the program module group requested at this time on the loading RAM by the CPU.
According to an eighteenth aspect of the present invention in the seventeenth aspect, the management programs further provides the steps of; deleting unnecessary program modules in the loading RAM when the empty capacity of the loading RAM is smaller than the total capacity of the extracted program modules, comparing again the total capacity of the extracted program modules with the empty capacity of the loading RAM after the unnecessary program modules were deleted, loading the extracted program modules into the loading RAM when the empty capacity of the loading RAM is larger than the total capacity of the extracted program modules, and executing the program module group requested at this time on the loading RAM by the CPU.
According to a nineteenth aspect of the present invention in the eighteenth aspect, the management programs further provides the steps of; comparing the total capacity of the program module group in the list table requested to be loaded with the total capacity of the loading RAM, when the empty capacity of the loading RAM after the unnecessary program modules were deleted is smaller than the total capacity of the extracted program modules, and executing the program module group requested at this time on the ROM by the CPU, when the total capacity of the program module group in the list table requested to be loaded is larger than the total capacity of the loading RAM.
According to a twentieth aspect of the present invention in the nineteenth aspect, the management programs further provides the steps of; deleting all the module management information in the loading RAM, when the total capacity of the program module group in the list table requested to be loaded is smaller than the total capacity of the loading RAM, loading the program module group in the list table requested to be loaded into the loading RAM, and executing the program module group requested at this time on the loading RAM by the CPU.
According to a twenty-first aspect of the present invention in the seventeenth aspect, the management programs further provides the steps of; stationing specified program modules permanently in the loading RAM when the loading RAM is initialized, and executing the specified program modules on the loading RAM without loading from the ROM by the CPU.
According to a twenty-second aspect of the present invention in the twenty-first aspect, the management programs further provides the steps of; comparing the total capacity of the program module group in the list table requested to be loaded with the total capacity of the loading RAM except that for the program modules stationed permanently, when the empty capacity of the loading RAM after the unnecessary program modules were deleted is smaller than the total capacity of the extracted program modules, and executing the program module group requested at this time on the ROM by the CPU, when the total capacity of the program module group in the list table requested to be loaded is larger than the total capacity of the loading RAM except that for the program modules stationed permanently.
According to a twenty-third aspect of the present invention in the twenty-first aspect, the management programs further provides the steps of; deleting all the module management information except that of the program modules stationed permanently in the loading RAM, when the total capacity of the program module group in the list table requested to be loaded is smaller than the total capacity of the loading RAM except that of the program modules stationed permanently, loading the program module group in the list table requested to be loaded into the loading RAM, and executing the program module group requested at this time on the loading RAM by the CPU.